1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.ComboRow;
26 
27 private import adw.ActionRow;
28 private import adw.c.functions;
29 public  import adw.c.types;
30 private import gio.ListModelIF;
31 private import glib.ConstructionException;
32 private import gobject.ObjectG;
33 private import gtk.Expression;
34 private import gtk.ListItemFactory;
35 private import gtk.Widget;
36 
37 
38 /**
39  * A [class@Gtk.ListBoxRow] used to choose from a list of items.
40  * 
41  * <picture>
42  * <source srcset="combo-row-dark.png" media="(prefers-color-scheme: dark)">
43  * <img src="combo-row.png" alt="combo-row">
44  * </picture>
45  * 
46  * The `AdwComboRow` widget allows the user to choose from a list of valid
47  * choices. The row displays the selected choice. When activated, the row
48  * displays a popover which allows the user to make a new choice.
49  * 
50  * `AdwComboRow` mirrors [class@Gtk.DropDown], see that widget for details.
51  * 
52  * `AdwComboRow` is [property@Gtk.ListBoxRow:activatable] if a model is set.
53  * 
54  * ## CSS nodes
55  * 
56  * `AdwComboRow` has a main CSS node with name `row` and the `.combo` style
57  * class.
58  * 
59  * Its popover has the node named `popover` with the `.menu` style class, it
60  * contains a [class@Gtk.ScrolledWindow], which in turn contains a
61  * [class@Gtk.ListView], both are accessible via their regular nodes.
62  * 
63  * ## Accessibility
64  * 
65  * `AdwComboRow` uses the `GTK_ACCESSIBLE_ROLE_COMBO_BOX` role.
66  *
67  * Since: 1.0
68  */
69 public class ComboRow : ActionRow
70 {
71 	/** the main Gtk struct */
72 	protected AdwComboRow* adwComboRow;
73 
74 	/** Get the main Gtk struct */
75 	public AdwComboRow* getComboRowStruct(bool transferOwnership = false)
76 	{
77 		if (transferOwnership)
78 			ownedRef = false;
79 		return adwComboRow;
80 	}
81 
82 	/** the main Gtk struct as a void* */
83 	protected override void* getStruct()
84 	{
85 		return cast(void*)adwComboRow;
86 	}
87 
88 	/**
89 	 * Sets our main struct and passes it to the parent class.
90 	 */
91 	public this (AdwComboRow* adwComboRow, bool ownedRef = false)
92 	{
93 		this.adwComboRow = adwComboRow;
94 		super(cast(AdwActionRow*)adwComboRow, ownedRef);
95 	}
96 
97 
98 	/** */
99 	public static GType getType()
100 	{
101 		return adw_combo_row_get_type();
102 	}
103 
104 	/**
105 	 * Creates a new `AdwComboRow`.
106 	 *
107 	 * Returns: the newly created `AdwComboRow`
108 	 *
109 	 * Since: 1.0
110 	 *
111 	 * Throws: ConstructionException GTK+ fails to create the object.
112 	 */
113 	public this()
114 	{
115 		auto __p = adw_combo_row_new();
116 
117 		if(__p is null)
118 		{
119 			throw new ConstructionException("null returned by new");
120 		}
121 
122 		this(cast(AdwComboRow*) __p);
123 	}
124 
125 	/**
126 	 * Gets the expression used to obtain strings from items.
127 	 *
128 	 * Returns: the expression used to obtain strings from items
129 	 *
130 	 * Since: 1.0
131 	 */
132 	public Expression getExpression()
133 	{
134 		auto __p = adw_combo_row_get_expression(adwComboRow);
135 
136 		if(__p is null)
137 		{
138 			return null;
139 		}
140 
141 		return ObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
142 	}
143 
144 	/**
145 	 * Gets the factory that's currently used to populate list items.
146 	 *
147 	 * Returns: the factory in use
148 	 *
149 	 * Since: 1.0
150 	 */
151 	public ListItemFactory getFactory()
152 	{
153 		auto __p = adw_combo_row_get_factory(adwComboRow);
154 
155 		if(__p is null)
156 		{
157 			return null;
158 		}
159 
160 		return ObjectG.getDObject!(ListItemFactory)(cast(GtkListItemFactory*) __p);
161 	}
162 
163 	/**
164 	 * Gets the factory that's currently used to populate list items in the popup.
165 	 *
166 	 * Returns: the factory in use
167 	 *
168 	 * Since: 1.0
169 	 */
170 	public ListItemFactory getListFactory()
171 	{
172 		auto __p = adw_combo_row_get_list_factory(adwComboRow);
173 
174 		if(__p is null)
175 		{
176 			return null;
177 		}
178 
179 		return ObjectG.getDObject!(ListItemFactory)(cast(GtkListItemFactory*) __p);
180 	}
181 
182 	/**
183 	 * Gets the model that provides the displayed items.
184 	 *
185 	 * Returns: The model in use
186 	 *
187 	 * Since: 1.0
188 	 */
189 	public ListModelIF getModel()
190 	{
191 		auto __p = adw_combo_row_get_model(adwComboRow);
192 
193 		if(__p is null)
194 		{
195 			return null;
196 		}
197 
198 		return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p);
199 	}
200 
201 	/**
202 	 * Gets the position of the selected item.
203 	 *
204 	 * Returns: the position of the selected item, or
205 	 *     [const@Gtk.INVALID_LIST_POSITION] if no item is selected
206 	 *
207 	 * Since: 1.0
208 	 */
209 	public uint getSelected()
210 	{
211 		return adw_combo_row_get_selected(adwComboRow);
212 	}
213 
214 	/**
215 	 * Gets the selected item.
216 	 *
217 	 * Returns: the selected item
218 	 *
219 	 * Since: 1.0
220 	 */
221 	public ObjectG getSelectedItem()
222 	{
223 		auto __p = adw_combo_row_get_selected_item(adwComboRow);
224 
225 		if(__p is null)
226 		{
227 			return null;
228 		}
229 
230 		return ObjectG.getDObject!(ObjectG)(cast(GObject*) __p);
231 	}
232 
233 	/**
234 	 * Gets whether to use the current value as the subtitle.
235 	 *
236 	 * Returns: whether to use the current value as the subtitle
237 	 *
238 	 * Since: 1.0
239 	 */
240 	public bool getUseSubtitle()
241 	{
242 		return adw_combo_row_get_use_subtitle(adwComboRow) != 0;
243 	}
244 
245 	/**
246 	 * Sets the expression used to obtain strings from items.
247 	 *
248 	 * The expression must have a value type of `G_TYPE_STRING`.
249 	 *
250 	 * Params:
251 	 *     expression = an expression
252 	 *
253 	 * Since: 1.0
254 	 */
255 	public void setExpression(Expression expression)
256 	{
257 		adw_combo_row_set_expression(adwComboRow, (expression is null) ? null : expression.getExpressionStruct());
258 	}
259 
260 	/**
261 	 * Sets the `GtkListItemFactory` to use for populating list items.
262 	 *
263 	 * Params:
264 	 *     factory = the factory to use
265 	 *
266 	 * Since: 1.0
267 	 */
268 	public void setFactory(ListItemFactory factory)
269 	{
270 		adw_combo_row_set_factory(adwComboRow, (factory is null) ? null : factory.getListItemFactoryStruct());
271 	}
272 
273 	/**
274 	 * Sets the `GtkListItemFactory` to use for populating list items in the popup.
275 	 *
276 	 * Params:
277 	 *     factory = the factory to use
278 	 *
279 	 * Since: 1.0
280 	 */
281 	public void setListFactory(ListItemFactory factory)
282 	{
283 		adw_combo_row_set_list_factory(adwComboRow, (factory is null) ? null : factory.getListItemFactoryStruct());
284 	}
285 
286 	/**
287 	 * Sets the [iface@Gio.ListModel] to use.
288 	 *
289 	 * Params:
290 	 *     model = the model to use
291 	 *
292 	 * Since: 1.0
293 	 */
294 	public void setModel(ListModelIF model)
295 	{
296 		adw_combo_row_set_model(adwComboRow, (model is null) ? null : model.getListModelStruct());
297 	}
298 
299 	/**
300 	 * Selects the item at the given position.
301 	 *
302 	 * Params:
303 	 *     position = the position of the item to select, or
304 	 *         [const@Gtk.INVALID_LIST_POSITION]
305 	 *
306 	 * Since: 1.0
307 	 */
308 	public void setSelected(uint position)
309 	{
310 		adw_combo_row_set_selected(adwComboRow, position);
311 	}
312 
313 	/**
314 	 * Sets whether to use the current value as the subtitle.
315 	 *
316 	 * Params:
317 	 *     useSubtitle = whether to use the current value as the subtitle
318 	 *
319 	 * Since: 1.0
320 	 */
321 	public void setUseSubtitle(bool useSubtitle)
322 	{
323 		adw_combo_row_set_use_subtitle(adwComboRow, useSubtitle);
324 	}
325 }